package org.sixtynine.stock.service.impl;

import java.util.List;

import org.sixtynine.stock.dao.SubSectorDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.SubSector;
import org.sixtynine.stock.service.SubSectorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Thilan
 *
 */

@Service
public class SubSectorServiceImpl implements SubSectorService {

	@Autowired
	private SubSectorDao subSectorDao;
	
	@Override
	public SubSector findById(int id) {
		return subSectorDao.findById(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void saveSubSector(SubSector subSector) {
		subSectorDao.saveSubSector(subSector);
	}

	@Override
	@Transactional(readOnly = false)
	public void deleteSubSector(int id) {
		SubSector subSector = subSectorDao.findById(id);
		if (subSector != null) {
			subSectorDao.delete(subSector);
		}
	}

	@Override
	public List<SubSector> findSubSector(String name) {
		return subSectorDao.findSubSectors(name);
	}

	@Override
	public List<SubSector> searchSubSector(int sectorId, String code) {
		return subSectorDao.searchSubSector(sectorId, code);
	}

	@Override
	public Page<SubSector> searchSubSector(int sectorId, String code,
			GridPramDTO gridPramDTO) {
		return subSectorDao.searchSubSector(sectorId, code, gridPramDTO);
	}

}
